package com.ibeeking.found.common.enums.goods;

import com.ibeeking.found.common.enums.marketing.CampaignSceneEnum;

/**
 * @Author ibeeking
 * @Date: 2021-01-05 19:15
 * @Description: 商品上架渠道enum
 */
public enum GoodsChannelEnum {
    // 商品上架渠道：-1商品列表、-2积分商城、-3线下POS
    GOODS(1, "商品列表"),
    BONUS_MALL(2, "积分商城"),
    POS(3, "线下POS"),;
    private Integer value;
    private String lable;

    GoodsChannelEnum(int value, String lable) {
        this.value = value;
        this.lable = lable;
    }


    public Integer getValue() {
        return value;
    }

    public String getLable() {
        return lable;
    }

    public static GoodsChannelEnum getEnum(Integer value) {
        for (GoodsChannelEnum enumObj : values()) {
            if (enumObj.getValue().equals(value)) {
                return enumObj;
            }
        }
        return null;
    }

    /**
     * 根据商品页面来源 获取渠道
     */
    public static Integer getChannelBySource(String source) {
        if (GOODS.toString().equals(source)) {
            return GOODS.getValue();
        } else if (BONUS_MALL.toString().equals(source)) {
            return BONUS_MALL.getValue();
        } else if (POS.toString().equals(source)) {
            return POS.getValue();
        } else if (CampaignSceneEnum.POINTS_MALLA_SCENE.toString().equals(source)) {
            return BONUS_MALL.getValue();
        } else {
            return GOODS.getValue();
        }
    }
}
